home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
batch
/
keyin11.zip
/
KEYIN.DOC
< prev
Wrap
Text File
|
1992-05-03
|
8KB
|
166 lines
┌──────┬─┬─┐
│ ┌─┐│ │ │
│┌─┐│ ││ │ │
││ │╪ ││ │ │
││─┤│ │└┬┘ │
││ │└─┘inc.│ ┌───────────────────────────────────────────┐
└┴─┴───────┘ ═╡ KEYin v1.1 Copyright (c) 1992 by ADV inc. ╞═
└───────────────────────────────────────────┘
INTRODUCTION
────────────
If this is the second time you have downloaded KEYin,
you might have noticed the version number. The old
KEYin program did not come with any version number. It
was supposed to be the only version to be published --
the program was too simple for any elaboration. The
reason this program now bears a version number is that a
major mistake was made in the documentation. There is
no change in the program itself; only this documentation
is altered. Anyway, KEYin is the tool you need to
create interactive batch files.
WHY ?
─────
I've seen many bulletin board messages regarding batch
file enhancements that allow you to do wonderful stuff
in batch file programming. They mentioned the use of
Norton Utilities' BE and other great programs. These
are great for you and I if we have the software, but
even though we do have the software, aren't they taking
a bit of space on your disk (I mean floppy!). And it
takes long time to load these programs. (How big is BE
really?) KEYin is only 300 bytes long! Another thing I
forgot to mention is you have to learn a new language
that is interpreted by these programs. Why not stick to
the old DOS's batch language?
SO WHAT ?
─────────
KEYin allows you to ask a user for input of a character.
The way to use it is where in your batch file you want
to ask a question that requires only a key press such as
a yes/no type question or a menu choice type, insert the
command KEYin (on a single line). When the batch file
is read at that point, the user will be prompted for a
key press. When the user presses a key, the ASCII code
of that key is passed from KEYin to the batch file in
the form of an ERRORLEVEL value. You could then check
the ERRORLEVEL to see which key has been press and
proceed accordingly.
FORMAT
──────
KEYin [x] [y] ["string"]
-x is an integer value ranging from 1 to 80.
-y is an integer value ranging from 1 to 25.
-string is a set of characters enclosed in quotation
marks.
If x or y is out of bound, the value will be corrected.
The string always starts with a quotation mark. It
doesn't have to end with one though, but it's a good
habit to end a string with the quotation mark isn't it?
With these parameters, KEYin will position the cursor at
(x,y), print a message (if any), and then asks for input
of a key.
HOW IT WORKS
────────────
KEYin will look for 2 numbers (the parameters you give)
first. That means 2 numbers -- not letters. Any
numbers afterwards don't count! Then it will search for
a string beginning with a quotation mark.
What all that means is that anything can be inserted
between the numbers and string. For example, the
following commands are all valid:
keyin 14 5 "Enter you choice: "
keyin 14 5 "Enter you choice: "
keyin 14,5,"Enter your choice: "
keyin junk14again5,what?"Enter your choice: "
keyin 14 5 3 4 2 "Enter your choice: "
keyin 14 5 3 4 2 "Enter your choice:
keyin 14 k5 5 3 Enter"Enter you choice:
All the above will result in the same output. Note that
some doesn't end with a quotation mark and that there
are extra number following the two first numbers.
EXAMPLE
───────
Here's an example how to implement KEYin:
@echo off
:START
cls
echo ╔════════════════════════════════════════════╗
echo ║ TODAY'S PROGRAM MENU BY ADV inc. ║
echo ║ ║
echo ║ 1. WordPerfect 5. Space Invaders ║
echo ║ 2. Lotus 1-2-3 6. Indiana Jones ║
echo ║ 3. Harvard Graphics ║
echo ║ 4. Telix 0. Quit ║
echo ║ ║
echo ║ Select a number: ║
echo ║ ║
echo ╚════════════════════════════════════════════╝
KEYin 20 9
if errorlevel == 55 goto START
if errorlevel == 54 goto INDY
if errorlevel == 53 goto SPACE
if errorlevel == 52 goto TELIX
if errorlevel == 51 goto GRAPHICS
if errorlevel == 50 goto 123
if errorlevel == 49 goto WP
if errorlevel == 48 goto END
goto START
:INDY
cd c:\games\indy
indy
cd c:\
goto START
.
.
.
:END
echo GoodBye!
Note that the keyin command does not print a string in
this case because none is provided. This shows how you
can implement KEYin in a menu system using batch
programming.
TRADEMARKS AND SO FORTH
───────────────────────
I hope you will find this program useful in your batch
file programming. At least, it does help me a little!
Enjoy batch programming!!
Here comes the fix for the error made in the previous
documentation. KEYin is NOT shareware or is it Public
Domain. KEYin is a free program. The program and
documentation are copyrighted. All rights reserved. If
you distribute it, do not leave this text file out
please.
All trademarks and copyrights belong to their respective
owners.